package com.msb.mall.product.web;

import com.msb.mall.product.entity.vo.SpuItemVo;
import com.msb.mall.product.service.SkuInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;

import java.util.concurrent.ExecutionException;

@Controller
public class ItemController {

    @Autowired
    SkuInfoService skuInfoService;
    /**
     * 根据前端的skuId查询对应的商品信息
     * @param skuId
     * @return
     */
    @GetMapping("/{skuId}.html")
    public String item(@PathVariable Long skuId, Model model) throws ExecutionException, InterruptedException {
        SpuItemVo item = skuInfoService.item(skuId);
        model.addAttribute("item",item);
        return "item";
    }

}
